home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / zendisk1.zip / LST7-9.ASM < prev    next >
Assembly Source File  |  1990-02-15  |  756b  |  30 lines

  1. ;
  2. ; *** Listing 7-9 ***
  3. ;
  4. ; Adds up the elements of a byte-sized array using
  5. ; base+index+displacement addressing inside the loop.
  6. ;
  7.     jmp    Skip
  8. ;
  9. ARRAY_LENGTH    equ    1000
  10. TestArray    db    ARRAY_LENGTH dup (1)
  11. TEST_START_OFFSET equ    200    ;we'll add elements 200-299
  12. TEST_LENGTH    equ    100    ; of TestArray
  13. ;
  14. Skip:
  15.     call    ZTimerOn
  16.     mov    bx,TEST_START_OFFSET
  17.                 ;for base+index+displacement
  18.     sub    si,si        ; addressing
  19.     sub    ax,ax        ;initialize sum
  20.     sub    dl,dl        ;store 0 in DL so we can use
  21.                 ; it for faster register-
  22.                 ; register adds in the loop
  23.     mov    cx,TEST_LENGTH    ;# of bytes to add
  24. SumArrayLoop:
  25.     add    al,[TestArray+bx+si] ;add in the next byte
  26.     adc    ah,dl        ; to the 16-bit sum
  27.     inc    si        ;point to next byte 
  28.     loop    SumArrayLoop
  29.     call    ZTimerOff
  30.